<? include 'server_config.php'; 
//include 'my_info_auth.php'; 


if($user_idx=="")
{
	
	?>
	<script>
		alert("권한이 없습니다.");
	</script>
	<?
	return;
}

?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?
/*
echo $hospital_idx.$q1.$q2.$q3.$q4.$q5;
echo "<br>";
foreach($drug as $drug_idx)
{
	echo $drug_idx." ";
}
echo "<br>";
foreach($test as $test_idx)
{
	echo $test_idx." ";
}
*/
$sql = "
INSERT INTO ndd_hospital_score (user_idx, hospital_idx) VALUES ($user_idx, $hospital_idx);
";

//echo $sql;
$result = mysql_query($sql,$connect);

$sql = "
UPDATE ndd_hospital_score SET q1=$q1, q2=$q2, q3=$q3, q4=$q4, q5=$q5, reg_timestamp=CURRENT_TIMESTAMP  WHERE user_idx = $user_idx AND hospital_idx = '$hospital_idx';
";

//echo $sql;
$result = mysql_query($sql,$connect);

$sql = "

DELETE FROM ndd_hospital_drug WHERE user_idx = $user_idx AND hospital_idx = '$hospital_idx';
";

//echo $sql;
$result = mysql_query($sql,$connect);

foreach($drug as $drug_idx)
{
	$sql = "

	INSERT INTO ndd_hospital_drug (user_idx, hospital_idx, list_drug_idx) VALUES ($user_idx, $hospital_idx, $drug_idx);
	";
	$result = mysql_query($sql,$connect);
}

$sql = "

DELETE FROM ndd_hospital_test WHERE user_idx = $user_idx AND hospital_idx = '$hospital_idx';
";

//echo $sql;
$result = mysql_query($sql,$connect);

foreach($test as $test_idx)
{
	$sql = "

	INSERT INTO ndd_hospital_test (user_idx, hospital_idx, list_test_idx) VALUES ($user_idx, $hospital_idx, $test_idx);
	";
	$result = mysql_query($sql,$connect);
}



?>

<script> 
location.href='hospital.php';
</script>











